//
//  OurClass.m
//  内存作业
//
//  Created by dllo on 15/12/10.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "OurClass.h"
#import "Teacher.h"
#import "Student.h"
@implementation OurClass

- (id)init{
    self = [super init];
    if (self) {
        self.students = [NSMutableArray array];
    }
    return self;
}

- (void)dealloc{
    [_teacher release];
    [_students release];
    [super dealloc];
    
}


- (void)changeTeacher:(Teacher *)teacher{
    
    self.teacher = teacher;
}

- (void)addStudent:(Student *)student{
    
    for (Student *stu in self.students) {
        if (stu.number == student.number) {
            return;
        }
    }
    [self.students addObject:student];
}

- (void)deleteStudent:(NSInteger)number{
    
    for (Student *stu in self.students) {
        if (stu.number == number) {
            [self.students removeObject:stu];
        }
    }
}

- (void)listAllStudent{
    for (Student *stu in self.students) {
        NSLog(@"%@",stu);
    }
}



@end
